<template>
  <div>
    <el-table
      :data="labList"
      :stripe="true"
      style="width: 100%">
      <el-table-column
        prop="id"
        label="编号">
      </el-table-column>
      <el-table-column
        prop="name"
        label="实验室名称">
      </el-table-column>
      <el-table-column
        prop="description"
        label="描述">
      </el-table-column>

      <el-table-column
        prop="capacity"
        label="座位">
      </el-table-column>

      <el-table-column
        label="操作">
        <template slot-scope="scope">
          <el-button @click="dialogVisible=true">预定</el-button>
          <el-button @click="deleteById(scope.row.id)">删除</el-button>
        </template>

      </el-table-column>
    </el-table>
    <router-view/>
    <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="30%"
      :before-close="handleClose">
      <el-form ref="add" :model="form" label-width="10xp">
        <el-form-item label="编号">
          <el-input v-model="form.id"></el-input>
        </el-form-item>
        <el-form-item label="实验室编号">
          <el-input v-model="form.lid"></el-input>
        </el-form-item>
        <el-form-item label="学生姓名">
          <el-input v-model="form.sid"></el-input>
        </el-form-item>
        <el-form-item label="预约时间">
          <el-input v-model="form.bookData"></el-input>
        </el-form-item>
        <el-form-item label="开始时间">
          <el-input v-model="form.startData"></el-input>
        </el-form-item>
        <el-form-item label="结束时间">
          <el-input v-model="form.endData"></el-input>
        </el-form-item>
        <el-form-item label="状态">
          <el-input v-model="form.state"></el-input>
        </el-form-item>
        <el-form-item label="原因">
          <el-input v-model="form.bookReason"></el-input>
        </el-form-item>
        <el-form-item label="实验室描述">
          <el-input v-model="form.descrption"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button @click="dialogVisible=false">取消</el-button>
          <el-button type="primary" @click="onSubmit">立即预约</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
    export default {
        name: "UserList",
      data(){
          return {
            labList:[],
            dialogVisible: false,
            form:{
              id:"",
              lid:"",
              sid:"",
              bookData:"",
              startData:"",
              endData:"",
              state:"",
              bookReason:"",
              descrption:""
            }
          }
      },
      created(){
        this.selectAll();
      },
      methods: {
        deleteById(id){
          this.$confirm("是否确认删除","删除提示").then(()=>{
            this.axios.delete("//del/"+id).then((resp)=>{
              this.$message.success("删除成功！");
              this.selectAll();
            });
          });
        },
        onSubmit(){

        },
        handleClose(){

        },
        selectAll(){
          this.axios.get("/laboratory/select").then((resp)=>{
            this.labList=resp.data;
          });
        }
      }
    }
</script>

<style scoped>

</style>
